﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="desktop.aspx.cs" Inherits="ZX.Web.UI.Controls.BasePage" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>主页面模板</title>
    <script src="/SFramework/boot.js"></script>
    <link href="/SFramework/miniui/themes/blue/skin.css" rel="stylesheet" />
    <link href="../../Styles/bootstrap.min.css" rel="stylesheet" />
    <link href="../../Styles/matrix-style.css" rel="stylesheet" />
    <script src="../../Scripts/app/edit.common.js"></script>
</head>
<body>
    <form id="form1" runat="server">
        <div class="row-fluid"></div>
        <div class="row-fluid">
            <div class="span6" id="divLeft">
            </div>
            <div class="span6" id="divRight">
            </div>
        </div>
    </form>
</body>
<script src="../../Scripts/common/jquery.data.js"></script>
</html>
<script type="text/javascript">
    //基于 jquery.data.js 取数
    var data = fnGetData("t_set_desktop", "", "sort");
    var DataMain = data.data;
    //html 模板定义
    var _template = '<div class="widget-box" style="height:[height]">' +
          '<div class="widget-title bg_ly" data-toggle="collapse" href="#[id]""><span class="icon"><i class="icon-chevron-down"></i></span>' +
          '<h5>[title]</h5>' +
          '</div>' +
          '<div class="widget-content nopadding collapse in" id="[id]">' +
           '<div class="content">[content]</div>' +
          '</div>' +
        '</div>';
    var _datatemp = "";
    for (var i = 0; i < DataMain.length; i++) {
        //0,内容ajax加载,1,iframe 页面加载
        var html = _template.replace("[title]", DataMain[i].title).replace("[id]", DataMain[i].id).replace("[height]", DataMain[i].height).replace("[content]", _datatemp);
        html = html.replace("[id]", DataMain[i].id);
        if (DataMain[i].area == "L") {
            $("#divLeft").append(html);
        }
        else {
            $("#divRight").append(html);
        }

        if (DataMain[i].content_type == "0") {
            getUrlData2(DataMain[i].data_url, $("#" + DataMain[i].id));
        }
        else {
            _datatemp = "<iframe scrolling=\"auto\" frameborder=\"0\"  src=\"" + DataMain[i].data_url + "\" style=\"width:100%;height:100%; margin:0px;\"></iframe>";
            $("#" + DataMain[i].id).html(_datatemp);
        }
    }
    //根据URL返回URL HTML内容
    function getUrlData2(url, targetEml) {
        if (url.indexOf("?") > 0) {
            url += "&r=" + Math.random();
        }
        else {
            url += "?r=" + Math.random();
        }
        $.ajaxSetup({
            error: function (x, e) {
                var myError = x.responseText;
                targetEml.html(myError);
            }
        });

        $.getJSON(url, function (_html) {
            targetEml.html(_html);
        });
    }

</script>
